﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AbpEntityFrameworkcore.Migrations
{
    /// <inheritdoc />
    public partial class _202593 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CusetomOrder",
                columns: table => new
                {
                    CusetomOrder_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    hSerial = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    moCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    So = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    State = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CusetomOrder", x => x.CusetomOrder_Id);
                });

            migrationBuilder.CreateTable(
                name: "Inlethouse",
                columns: table => new
                {
                    Id_Inlethouse = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    InlethouseCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "仓库号"),
                    Xaxis = table.Column<int>(type: "int", nullable: false, comment: "排"),
                    Yaxis = table.Column<int>(type: "int", nullable: false, comment: "高"),
                    Zaxis = table.Column<int>(type: "int", nullable: false, comment: "列"),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Inlethouse", x => x.Id_Inlethouse);
                });

            migrationBuilder.CreateTable(
                name: "lognote",
                columns: table => new
                {
                    Id_logNote = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Note = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    User = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Definition = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MaterialCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MaterialName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Batch = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Size = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_lognote", x => x.Id_logNote);
                });

            migrationBuilder.CreateTable(
                name: "MaterialOrder",
                columns: table => new
                {
                    Id_MaterialOder = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    MaterialOrderName = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "工单名"),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "入库or出库"),
                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialOrder", x => x.Id_MaterialOder);
                });

            migrationBuilder.CreateTable(
                name: "SowingWall",
                columns: table => new
                {
                    SowingWall_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SowingWall_Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SowingWall_Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Xaxis = table.Column<int>(type: "int", nullable: true),
                    Yaxis = table.Column<int>(type: "int", nullable: true),
                    Mchine = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SowingWall", x => x.SowingWall_Id);
                });

            migrationBuilder.CreateTable(
                name: "Warehouse",
                columns: table => new
                {
                    Id_Warehouse = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    WarehouseCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "仓库号"),
                    Xaxis = table.Column<int>(type: "int", nullable: false, comment: "排"),
                    Yaxis = table.Column<int>(type: "int", nullable: false, comment: "高"),
                    Zaxis = table.Column<int>(type: "int", nullable: false, comment: "列"),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Warehouse", x => x.Id_Warehouse);
                });

            migrationBuilder.CreateTable(
                name: "CusetomOrderLine",
                columns: table => new
                {
                    CusetomOrderLine_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    reelId = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    quantity = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    slotNum = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    State = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    mtrlCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CusetomOrder_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CusetomOrderLine", x => x.CusetomOrderLine_Id);
                    table.ForeignKey(
                        name: "FK_CusetomOrderLine_CusetomOrder_CusetomOrder_Id",
                        column: x => x.CusetomOrder_Id,
                        principalTable: "CusetomOrder",
                        principalColumn: "CusetomOrder_Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "InlethouseLine",
                columns: table => new
                {
                    Id_InlethouseLine = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    InlethouseLineCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Long = table.Column<int>(type: "int", nullable: false),
                    Wide = table.Column<int>(type: "int", nullable: false),
                    high = table.Column<int>(type: "int", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "入口/出口"),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false, comment: "是否使能"),
                    Xaxis = table.Column<int>(type: "int", nullable: false, comment: "排"),
                    Yaxis = table.Column<int>(type: "int", nullable: false, comment: "高"),
                    Zaxis = table.Column<int>(type: "int", nullable: false, comment: "列"),
                    TheInlethouseId_Inlethouse = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InlethouseLine", x => x.Id_InlethouseLine);
                    table.ForeignKey(
                        name: "FK_InlethouseLine_Inlethouse_TheInlethouseId_Inlethouse",
                        column: x => x.TheInlethouseId_Inlethouse,
                        principalTable: "Inlethouse",
                        principalColumn: "Id_Inlethouse",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "WorkerOrder",
                columns: table => new
                {
                    Id_WorkerOrder = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "上架or下架"),
                    StartPlace = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "起始位置"),
                    EndPlace = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "目标位置"),
                    BoxCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "箱盒"),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    TheMaterialOrederId_MaterialOder = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkerOrder", x => x.Id_WorkerOrder);
                    table.ForeignKey(
                        name: "FK_WorkerOrder_MaterialOrder_TheMaterialOrederId_MaterialOder",
                        column: x => x.TheMaterialOrederId_MaterialOder,
                        principalTable: "MaterialOrder",
                        principalColumn: "Id_MaterialOder",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "SowingWallLine",
                columns: table => new
                {
                    SowingWallLine_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SowingWallLine_Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Xaxis = table.Column<int>(type: "int", nullable: true),
                    Yaxis = table.Column<int>(type: "int", nullable: true),
                    Mchine = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsOccupy = table.Column<bool>(type: "bit", nullable: false),
                    BoxCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    SowingWall_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SowingWallLine", x => x.SowingWallLine_Id);
                    table.ForeignKey(
                        name: "FK_SowingWallLine_SowingWall_SowingWall_Id",
                        column: x => x.SowingWall_Id,
                        principalTable: "SowingWall",
                        principalColumn: "SowingWall_Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "WarehouseLine",
                columns: table => new
                {
                    Id_WarehouseLine = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    WarehouseLineCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Long = table.Column<int>(type: "int", nullable: false),
                    Wide = table.Column<int>(type: "int", nullable: false),
                    high = table.Column<int>(type: "int", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false, comment: "是否使能"),
                    IsOccupy = table.Column<bool>(type: "bit", nullable: false, comment: "是否占用"),
                    Xaxis = table.Column<int>(type: "int", nullable: false, comment: "排"),
                    Yaxis = table.Column<int>(type: "int", nullable: false, comment: "高"),
                    Zaxis = table.Column<int>(type: "int", nullable: false, comment: "列"),
                    TheWarehouseId_Warehouse = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WarehouseLine", x => x.Id_WarehouseLine);
                    table.ForeignKey(
                        name: "FK_WarehouseLine_Warehouse_TheWarehouseId_Warehouse",
                        column: x => x.TheWarehouseId_Warehouse,
                        principalTable: "Warehouse",
                        principalColumn: "Id_Warehouse",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Box",
                columns: table => new
                {
                    Id_Box = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    BoxCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    BoxGridQuantity = table.Column<int>(type: "int", nullable: false, comment: "格口数"),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false, comment: "允许使用"),
                    Info = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Remarks = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Id_WarehouseLine = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    Id_InlethouseLine = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Box", x => x.Id_Box);
                    table.ForeignKey(
                        name: "FK_Box_InlethouseLine_Id_InlethouseLine",
                        column: x => x.Id_InlethouseLine,
                        principalTable: "InlethouseLine",
                        principalColumn: "Id_InlethouseLine");
                    table.ForeignKey(
                        name: "FK_Box_WarehouseLine_Id_WarehouseLine",
                        column: x => x.Id_WarehouseLine,
                        principalTable: "WarehouseLine",
                        principalColumn: "Id_WarehouseLine");
                });

            migrationBuilder.CreateTable(
                name: "BoxGrid",
                columns: table => new
                {
                    Id_BoxGrid = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Sequence = table.Column<int>(type: "int", nullable: false, comment: "格口序号"),
                    BoxGridCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "格口号"),
                    BoxPositionQuantity = table.Column<int>(type: "int", nullable: false, comment: "货位数"),
                    TheBoxId_Box = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BoxGrid", x => x.Id_BoxGrid);
                    table.ForeignKey(
                        name: "FK_BoxGrid_Box_TheBoxId_Box",
                        column: x => x.TheBoxId_Box,
                        principalTable: "Box",
                        principalColumn: "Id_Box",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TaskOrder",
                columns: table => new
                {
                    Id_TaskOrder = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreatTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "任务类型"),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    State = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "任务状态-未下发/已下发"),
                    Id_Box = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    WarehouseCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "仓库坐标"),
                    InlethouseCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "缓存坐标"),
                    TaskOrderCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "任务号")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TaskOrder", x => x.Id_TaskOrder);
                    table.ForeignKey(
                        name: "FK_TaskOrder_Box_Id_Box",
                        column: x => x.Id_Box,
                        principalTable: "Box",
                        principalColumn: "Id_Box",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MaterialBase",
                columns: table => new
                {
                    Id_Materialbase = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    MaterialName = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "物料号"),
                    MaterialCode = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "Lpn"),
                    Batch = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "批次号"),
                    Size = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "物料大小"),
                    Quantity = table.Column<int>(type: "int", nullable: true, comment: "1个单位物料数量"),
                    Unit = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "单位"),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "类型"),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "说明"),
                    IsDelete = table.Column<bool>(type: "bit", nullable: true, comment: "是否删除"),
                    Info = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BoxGridId_BoxGrid = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialBase", x => x.Id_Materialbase);
                    table.ForeignKey(
                        name: "FK_MaterialBase_BoxGrid_BoxGridId_BoxGrid",
                        column: x => x.BoxGridId_BoxGrid,
                        principalTable: "BoxGrid",
                        principalColumn: "Id_BoxGrid");
                });

            migrationBuilder.CreateTable(
                name: "NeetOutMaterial",
                columns: table => new
                {
                    Id_NeetOutMaterial = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "需求工单"),
                    NeetQuantity = table.Column<int>(type: "int", nullable: true, comment: "需求数量"),
                    remark = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: " 说明-实际需求数量"),
                    moCode = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "工单号"),
                    slotNum = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "站位号"),
                    MaterialId_Materialbase = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NeetOutMaterial", x => x.Id_NeetOutMaterial);
                    table.ForeignKey(
                        name: "FK_NeetOutMaterial_MaterialBase_MaterialId_Materialbase",
                        column: x => x.MaterialId_Materialbase,
                        principalTable: "MaterialBase",
                        principalColumn: "Id_Materialbase",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "T_MaterialBases_MaterialOrders",
                columns: table => new
                {
                    MaterialOrdersId_MaterialOder = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    materialBasesId_Materialbase = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_MaterialBases_MaterialOrders", x => new { x.MaterialOrdersId_MaterialOder, x.materialBasesId_Materialbase });
                    table.ForeignKey(
                        name: "FK_T_MaterialBases_MaterialOrders_MaterialBase_materialBasesId_Materialbase",
                        column: x => x.materialBasesId_Materialbase,
                        principalTable: "MaterialBase",
                        principalColumn: "Id_Materialbase",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_T_MaterialBases_MaterialOrders_MaterialOrder_MaterialOrdersId_MaterialOder",
                        column: x => x.MaterialOrdersId_MaterialOder,
                        principalTable: "MaterialOrder",
                        principalColumn: "Id_MaterialOder",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Box_Id_InlethouseLine",
                table: "Box",
                column: "Id_InlethouseLine",
                unique: true,
                filter: "[Id_InlethouseLine] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_Box_Id_WarehouseLine",
                table: "Box",
                column: "Id_WarehouseLine",
                unique: true,
                filter: "[Id_WarehouseLine] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_BoxGrid_TheBoxId_Box",
                table: "BoxGrid",
                column: "TheBoxId_Box");

            migrationBuilder.CreateIndex(
                name: "IX_CusetomOrderLine_CusetomOrder_Id",
                table: "CusetomOrderLine",
                column: "CusetomOrder_Id");

            migrationBuilder.CreateIndex(
                name: "IX_InlethouseLine_TheInlethouseId_Inlethouse",
                table: "InlethouseLine",
                column: "TheInlethouseId_Inlethouse");

            migrationBuilder.CreateIndex(
                name: "IX_MaterialBase_BoxGridId_BoxGrid",
                table: "MaterialBase",
                column: "BoxGridId_BoxGrid");

            migrationBuilder.CreateIndex(
                name: "IX_NeetOutMaterial_MaterialId_Materialbase",
                table: "NeetOutMaterial",
                column: "MaterialId_Materialbase");

            migrationBuilder.CreateIndex(
                name: "IX_SowingWallLine_SowingWall_Id",
                table: "SowingWallLine",
                column: "SowingWall_Id");

            migrationBuilder.CreateIndex(
                name: "IX_T_MaterialBases_MaterialOrders_materialBasesId_Materialbase",
                table: "T_MaterialBases_MaterialOrders",
                column: "materialBasesId_Materialbase");

            migrationBuilder.CreateIndex(
                name: "IX_TaskOrder_Id_Box",
                table: "TaskOrder",
                column: "Id_Box",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_WarehouseLine_TheWarehouseId_Warehouse",
                table: "WarehouseLine",
                column: "TheWarehouseId_Warehouse");

            migrationBuilder.CreateIndex(
                name: "IX_WorkerOrder_TheMaterialOrederId_MaterialOder",
                table: "WorkerOrder",
                column: "TheMaterialOrederId_MaterialOder");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CusetomOrderLine");

            migrationBuilder.DropTable(
                name: "lognote");

            migrationBuilder.DropTable(
                name: "NeetOutMaterial");

            migrationBuilder.DropTable(
                name: "SowingWallLine");

            migrationBuilder.DropTable(
                name: "T_MaterialBases_MaterialOrders");

            migrationBuilder.DropTable(
                name: "TaskOrder");

            migrationBuilder.DropTable(
                name: "WorkerOrder");

            migrationBuilder.DropTable(
                name: "CusetomOrder");

            migrationBuilder.DropTable(
                name: "SowingWall");

            migrationBuilder.DropTable(
                name: "MaterialBase");

            migrationBuilder.DropTable(
                name: "MaterialOrder");

            migrationBuilder.DropTable(
                name: "BoxGrid");

            migrationBuilder.DropTable(
                name: "Box");

            migrationBuilder.DropTable(
                name: "InlethouseLine");

            migrationBuilder.DropTable(
                name: "WarehouseLine");

            migrationBuilder.DropTable(
                name: "Inlethouse");

            migrationBuilder.DropTable(
                name: "Warehouse");
        }
    }
}
